/***********************************************************************
 * 描述:		点击+n后显示 n个标签(CxiTagWidget)
 * File:    cxipopupbox.h
 * Author:  chenanqi@mozihealthcare.cn
 * Date:    2025/10/16 10:50
 * Update:
 **********************************************************************/

#ifndef COREXI_COMMON_PC_CXIPOPUPBOX_H
#define COREXI_COMMON_PC_CXIPOPUPBOX_H

#include <QWidget>
#include <QLabel>
#include <QTimer>
#include <QPropertyAnimation>
#include <QEvent>
#include <QObject>

class CxiFlowLayout;

class CxiPopupBox : public QWidget
{
	Q_OBJECT
public:
	explicit CxiPopupBox(QWidget* parent = nullptr);
	~CxiPopupBox() override = default;

	void setCount(int count);

	void addTag(QWidget* tag);

	void clearTags();

protected:
	void enterEvent(QEvent* ev) override;
	void leaveEvent(QEvent* ev) override;
	bool eventFilter(QObject* watched, QEvent* event) override;

private:
	void showPopupAtProperPos();
	void hidePopupIfNeeded();

	QLabel* m_label;
	QWidget* m_popup;
	QWidget* m_popupContainer;
	CxiFlowLayout* m_flow;
	QTimer* m_hideTimer;
	QPropertyAnimation* m_fadeAnim;
};

#endif // COREXI_COMMON_PC_CXIPOPUPBOX_H
